﻿#include<iostream>
#include<bitset>
using namespace std;
int main() {

	int test1{ 0xFFFF };
	test1 = ~test1;//求反
	cout << bitset<32>(test1) << endl;

	int test2{ 0x2833 };
	test2 = test2 & 0xFF00;
	cout << bitset<32>(test2) << endl;


	int test{ -100 };//正数补0，负数补1
	test >>= 1;
	cout << test << endl;

	int a{ (int)0b11111111111111111111111111111111 };//0xFFFFFFFF带符号的整数值
	cout << a << endl;
	cout << bitset<32>(a) << endl;
	a <<= 8;
	cout << bitset<32>(a) << endl;//<>中填写保存位数
	a >>= 8;
	cout << bitset<32>(a) << endl;


	cout << endl;

	unsigned b{ (unsigned)a };
	cout << bitset<32>(b) << endl;
	b <<= 7;
	cout << bitset<32>(b) << endl;

	a >>= 7;
	cout << bitset<32>(a) << endl;//左移乘，右移除

	int c{ 100 };
	c >>= 2;
	cout << bitset<32>(c) << endl;
}

//int与unsigned int补位区别
//unsigned int是无符号数，没有正负之分，所以左移右移都是补0
//int是有符号数，有正负之分
//当int的数是正数时，和unsigned int一样左移右移都是补0，
//当int的数时负数时，右移补0，左移补1